<?php
$cid = $_GET['cid'];
$action = $_GET['action'];
$do = $_GET['do'];

if($do == 'contact') {
	$pagefile = 'contact';
}

if (!$cid && !$action && !$do) {
	$date = date("Y.m.d");
	$query_sql = "SELECT a.articleid,a.cid,a.dateline,a.title,a.alias,a.description,a.content,a.keywords,c.name as cname,c.url as curl FROM {$db_prefix}articles a LEFT JOIN {$db_prefix}categories c ON c.cid=a.cid WHERE a.visible='1' AND a.stick='1' ORDER BY a.dateline DESC
LIMIT 0 , 3";
	$query = $DB->query($query_sql);
	$diyarticledb = array();
	$diyarticlenewsdb = array();
	while ($diyarticle = $DB->fetch_array($query)) {
		$diyarticle['url'] = getpermalink($diyarticle['articleid'], $diyarticle['alias'], 0, sadate('Y/m/d',$diyarticle['dateline']));
		$diyarticle['dateline'] = sadate('Y-m-d',$diyarticle['dateline']);
		if (empty($diyarticle['description'])) {
			$diyarticle['content'] = trimmed_title(html2text(preg_replace("/\[attach=(\d+)\]/ie", "", $diyarticle['content'])), 160);
		} else {
			$diyarticle['content'] = trimmed_title(html2text($diyarticle['description']), 160);
		}
		$diyarticle['title'] = trimmed_title($diyarticle['title'], $options['title_limit']);
		//TAGS
		if ($diyarticle['keywords']) {
			$diyarticletags = $tmark = '';
			$tagdb = explode(',', $diyarticle['keywords']);
			foreach($tagdb as $tag) {
				$tag = trim($tag);
				$diyarticletags .= $tmark.'<a href="'.gettaglink(urlencode($tag)).'">'.htmlspecialchars($tag).'</a>';
				$tmark = ', ';
				$diyarticle['content'] = highlight_tag($diyarticle['content'], $tag);
			}
			$diyarticle['alltags'] = $diyarticletags;
		}
		$diyarticle['cateurl'] = getcatelink($diyarticle['cid'], $diyarticle['curl']);
		
		$diyarticlenewsdb[] = $diyarticle;
		unset($diyarticletags);
	}
	
	unset($diyarticle);
	$DB->free_result($query);

	$pagefile = 'cms';
}
?>